package org.mine.design.builder.service.impl;

import org.mine.design.builder.controller.param.RequestParam;
import org.mine.design.builder.data.ActivityAwardCost;
import org.mine.design.builder.service.ActivityAwardCalculateService;
import org.springframework.stereotype.Service;

@Service
public class ActivityAwardCalculateServiceImpl implements ActivityAwardCalculateService {

    @Override
    public int calculate(RequestParam param) {
        int completeOrderQuantity = param.getCompleteOrderQuantity();
        return ActivityAwardCost.getActivityCostList().stream()
                .filter(source -> source.getCompleteCondition() == completeOrderQuantity)
                .map(ActivityAwardCost::getCompleteCost)
                .findFirst()
                .orElse(0);
    }
}
